/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.FundamentalActivities;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.Kernel.Constraint;
import edu.pku.sei.modeler.model.uml.Kernel.Constraint;
import edu.pku.sei.modeler.model.uml.BasicActions.OutputPin;
import edu.pku.sei.modeler.model.uml.BasicActions.InputPin;
import edu.pku.sei.modeler.model.uml.ExtraStructuredActivities.ExceptionHandler;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;


/**
 * @generated
 *
 */
public class Action extends ActivityNode implements IAction {
	// attributes
	
	
	
	
	// references
	
	protected MetaTypedList localPostcondition;
	
	protected MetaTypedList localPrecondition;
	
	protected MetaTypedList output;
	
	protected MetaTypedList input;
	
	protected MetaTypedList protectedNode;
	
	public Action(){
		this.name = "unnamed action";
	}
	
	// getters & setters for attributes
	
	// getters for references
	
	public MetaTypedList getLocalPostcondition() {
		if(localPostcondition == null) {
			localPostcondition = new MetaTypedList(Constraint.class, this, ModelPackage.ACTION_LOCALPOSTCONDITION);
		}
		return localPostcondition;
	}
	
	public MetaTypedList getLocalPrecondition() {
		if(localPrecondition == null) {
			localPrecondition = new MetaTypedList(Constraint.class, this, ModelPackage.ACTION_LOCALPRECONDITION);
		}
		return localPrecondition;
	}
	
	public MetaTypedList getOutput() {
		if(output == null) {
			output = new MetaTypedList(OutputPin.class, this, ModelPackage.ACTION_OUTPUT);
		}
		return output;
	}
	
	public MetaTypedList getInput() {
		if(input == null) {
			input = new MetaTypedList(InputPin.class, this, ModelPackage.ACTION_INPUT);
		}
		return input;
	}
	
	public MetaTypedList getProtectedNode() {
		if(protectedNode == null) {
			protectedNode = new MetaTypedList(ExceptionHandler.class, this, ModelPackage.EXECUTABLENODE_PROTECTEDNODE);
		}
		return protectedNode;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTION_LOCALPOSTCONDITION, localPostcondition);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTION_LOCALPRECONDITION, localPrecondition);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ACTION_OUTPUT, output);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ACTION_INPUT, input);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.EXECUTABLENODE_PROTECTEDNODE, protectedNode);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		// references
		
		this.getLocalPostcondition().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTION_LOCALPOSTCONDITION, this));
		
		this.getLocalPrecondition().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTION_LOCALPRECONDITION, this));
		
		this.getOutput().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ACTION_OUTPUT));
		
		this.getInput().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ACTION_INPUT));
		
		this.getProtectedNode().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.EXECUTABLENODE_PROTECTEDNODE, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.ACTION_LOCALPOSTCONDITION.equals(featureID)) {
			getLocalPostcondition().add(value);
		}
		
		else if(ModelPackage.ACTION_LOCALPRECONDITION.equals(featureID)) {
			getLocalPrecondition().add(value);
		}
		
		else if(ModelPackage.EXECUTABLENODE_PROTECTEDNODE.equals(featureID)) {
			getProtectedNode().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 